package com.hro.hro_app.background;

import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class BootReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {

		if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {

			AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
			Intent i = new Intent(context, DataRefreshTask.class);
			PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, 0);
			am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 4 * AlarmManager.INTERVAL_HOUR, pi);
		}
	}
}